package com.kimoge.spring6.resources.resourceloader;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import org.springframework.core.io.Resource;

import java.io.IOException;
import java.io.InputStream;

/**
 * @author kimoge
 * @date 2025/8/30
 * @description
 */
public class Demo2 {
    public static void main(String[] args) {
        ApplicationContext context = new FileSystemXmlApplicationContext();
        Resource resource = context.getResource("file:properties.txt");
        try {
            InputStream inputStream = resource.getInputStream();
            byte[] bytes = new byte[inputStream.available()];
            inputStream.read(bytes);
            System.out.println(new String(bytes));
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
